package com.chuyu.cy.utils;

import com.chuyu.cy.entity.domain.User;
import com.chuyu.cy.entity.vo.UserVo;

import java.util.List;

/**
 * @author: 周小白
 * @date: 2024-03-16 19:14
 **/
public class Common {

    public static UserVo userToUserVo(User user) {
        UserVo userVo = new UserVo();

        userVo.setId(user.getId());
        userVo.setNickName(user.getNickName());
        userVo.setStuId(user.getStuId());
        userVo.setCreditScore(user.getCreditScore());
        userVo.setAvatar(user.getAvatar());
        userVo.setGender(user.getGender());
        userVo.setContact(user.getContact());
        userVo.setTags(user.getTags());
        userVo.setDescription(user.getDescription());
        userVo.setCreateTime(user.getCreateTime());

        return userVo;
    }


    public static List<User> toSafeUserList(List<User> users) {
        for (User user : users) {
            user.setCreateTime(null);
            user.setUpdateTime(null);
            user.setIsDelete(null);
        }
        return users;
    }

}
